package com.easy.customer.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.easy.common.bean.CustomerInteractions;
import com.easy.common.service.ICustomerInteractionsService;
import com.easy.customer.mapper.CustomerInteractionsMapper;
import com.easy.customer.mapper.CustomerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CustomerInteractionsService implements ICustomerInteractionsService {
    @Autowired
    CustomerInteractionsMapper customerInteractionsMapper;
    @Override
    public CustomerInteractions insert(CustomerInteractions interactions) {
        customerInteractionsMapper.insert(interactions);
        CustomerInteractions result=this.getByID(interactions.getId());
        return result;
    }

    @Override
    public CustomerInteractions update(CustomerInteractions interactions) {
        customerInteractionsMapper.updateById(interactions);
        CustomerInteractions result=this.getByID(interactions.getId());
        return result;
    }

    @Override
    public IPage<CustomerInteractions> getListByPage(IPage page, CustomerInteractions interactions) {
        Wrapper wrapper=new QueryWrapper(interactions);
        IPage<CustomerInteractions> result=customerInteractionsMapper.selectPage(page, wrapper);
        return result;
    }

    @Override
    public CustomerInteractions getByID(Integer id) {
        CustomerInteractions result=customerInteractionsMapper.selectById(id);
        return result;
    }
}
